﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
namespace UI.ModEmployee
{
    public partial class DefDutyGroup : System.Web.UI.Page
    {
        DutyBiz dutyBiz = new DutyBiz();
        IBizSQL bizSQL = new BizSQL();
        protected void Page_Load(object sender, EventArgs e)
        {
            //
            if (Request.Params["DelParam"]!=null)
            {
                bizSQL.ExecSQL("delete from Admin_Emp_DutyGroup where EmpCode='" + Request.Params["DelParam"].ToString() + "'");            
            }
            if (!IsPostBack)
            {
                StringBuilder builder = new StringBuilder("<table width=\"100%\">");
                DataTable dt = dutyBiz.GetGroupList();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count;i++ ) 
                    {
                        builder.Append("<tr>");
                        builder.Append("<td>");
                        builder.Append(dt.Rows[i]["EmpCode"].ToString());
                        builder.Append("</td>");

                        builder.Append("<td>");
                        builder.Append(dt.Rows[i]["EmpName"].ToString());
                        builder.Append("</td>");

                        builder.Append("<td>");
                        builder.Append(dt.Rows[i]["DeptName"].ToString());
                        builder.Append("</td>");

                        DataTable dd = dutyBiz.GetListsByArray(dt.Rows[i]["DutyArray"].ToString());
                        if (dd.Rows.Count > 0)
                        {
                           
                                builder.Append("<td>");
                                for (int j = 0; j < dd.Rows.Count; j++)
                                {
                                    builder.Append(dd.Rows[j]["DutyName"].ToString()+"   ");
                                }
                            builder.Append("</td>");
                        }

                        builder.Append("<td>");
                        builder.Append("<a href=DefDutyGroup.aspx?DelParam=" + dt.Rows[i]["EmpCode"].ToString() + ">删除</a>");
                        builder.Append("</td>");
                        builder.Append("</tr>");
                    }
                    builder.Append("</table>");

                    Literal1.Text = builder.ToString();
                }
            }
        }
    }
}